<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../../css/mui.min.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/html-base.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/public.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/list.css"/>
    <script type="text/javascript" src="../../script/jquery.min.js"></script>
    <script type="text/javascript" src="../../script/newresize.js"></script>
    <script type="text/javascript" src="../../script/mui.min.js"></script>
    <style type="text/css">
    	body,html{height: 100%;overflow: hidden;}
    	.header{position: static;}
    	.applycontainer{padding-top: 0;width: 100%;}
    </style>
</head>
<body>
	<!-- <header class="header fix-header">
		<a class="mui-action-back mui-icon mui-icon-left-nav"></a>
		<h1 class="mui-title">个人申请实习页面</h1>
	</header> -->
	<div class="container applycontainer">
		<p class="apply-tit">请如实填写以下个人信息</p>
		<form>
			<div class="applyitem">
				<label>姓　　名</label>
				<input type="text" name="" id="uname" value="" placeholder="请输入姓名"/>
			</div>
			<div class="applyitem">
				<label>性　　别</label>
				<div class="radiobox"><input type="radio" name="sex" id="man" value="" /><label for="man">男</label></div>
				<div class="radiobox"><input type="radio" name="sex" id="women" value="" /><label for="women">女</label></div>
			</div>
			<div class="applyitem">
				<label>院　　校</label>
				<input type="text" name="" id="schoolname" value="" placeholder="请输入院校名称"/>
			</div>
			<div class="applyitem">
				<label>开始实习时间</label>
				<input type="text" name="" id="time-start" class="test-item" placeholder="请选择开始实习时间" readonly=""/>
			</div>
			<div class="applyitem">
				<label>结束实习时间</label>
				<input type="text" name="" id="time-end" class="test-item" placeholder="请选择结束实习时间" readonly=""/>
			</div>
			<div class="applyitem">
				<label>联系电话</label>
				<input type="text" id="phonenumber" maxlength="13" placeholder="请输入联系电话"/>
			</div>
			<div class="applyitem">
				<label>微　　信</label>
				<input type="text" name="" id="wechat" value="" placeholder="请输入微信号"/>
			</div>
		</form>
		<p class="tips-txt1">团体申请请联系：13800288829</p>
		<div class="apply-submit" onclick="submitClick()">提交</div>
	</div>

<script type="text/javascript" src="../../script/laydate/laydate.js"></script>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/MD5.js"></script>
<script type="text/javascript" src="../../script/requestTool.js"></script>
<script type="text/javascript" src="../../script/timeStampTool.js"></script>
<script type="text/javascript">
	mui.plusReady(function(){
        // 在这里调用plus api
        plus.webview.currentWebview().setStyle({  
		    softinputMode: "adjustResize"  // 弹出软键盘时自动改变webview的高度  
		}); 
    });
	$(function(){
		//时间插件
		lay('.test-item').each(function(){
			laydate.render({
				elem: this,
				format: 'yyyy/MM/dd',
				trigger: 'click' ,
				theme: 'xxx',
				ready: function(date){
					//插件初始化打开时调整显示的位置
				    $(".laydate-theme-xxx").css({"left":"50%","margin-left":"-110px","margin-bottom":"20px"});
				},
				done: function(value, date, endDate){
				    // console.log(value); //得到日期生成的值，如：2017-08-18
				    // console.log(date); //得到日期时间对象：{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
				    // console.log(endDate); //得结束的日期时间对象，开启范围选择（range: true）才会返回。对象成员同上。
				}
			});
		});
	});
	apiready = function(){
	    
	}
	function isSpace(str){
		if (str == null || str == '' || str.replace(/(^\s*)|(\s*$)/g, "") == '') {
            return true;
        }
        return false;
	}
	function submitClick(){
		//姓名
		var uname = $('#uname').val();
		if (isSpace(uname)) {
			api.toast({
			    msg: '请输入姓名'
			});
			return;
		}
		//性别
		var manVal = $('input:radio[id="man"]:checked').val();
		var womenVal = $('input:radio[id="women"]:checked').val();
		if (manVal == undefined && womenVal == undefined) {
			api.toast({
			    msg: '请选择性别'
			});
			return;
		}
		var sex = manVal == undefined ? 1 : 0;
		//院校
		var schoolname = $('#schoolname').val();
		if (isSpace(schoolname)) {
			api.toast({
			    msg: '请输入院校名称'
			});
			return;
		}
		//开始时间
		var startTime = $('#time-start').val();
		if (startTime == '') {
			api.toast({
			    msg: '请选择开始实习时间'
			});
			return;
		}
		var stime = timeStamp10WithString(startTime);
		//结束时间
		var endTime = $('#time-end').val();
		if (endTime == '') {
			api.toast({
			    msg: '请选择实习结束时间'
			});
			return;
		}
		var etime = timeStamp10WithString(endTime);
		//电话
		var phonenumber = $('#phonenumber').val();
		if (isSpace(phonenumber)) {
			api.toast({
			    msg: '请输入电话号码'
			});
			return;
		}
		//微信号
		var wechat = $('#wechat').val();
		var params = {
			uid : $api.getStorage('cfnetppuid'),
			uname : uname,
			sex : sex,
			schoolname : schoolname,
			starttime : stime,
			endtime : etime,
			phonenum : phonenumber,
			wechat : wechat,
			gwid : api.pageParam.id 
		};
		applySubmit(params);
	}
	function applySubmit(params){
		api.showProgress({
		    style: 'default',
		    animationType: 'fade',
		    title: '提交中...',
		    text: '',
		    modal: true
		});
		cfnetppPOST(url_newPracticeApply, params, false, function(data, status){
			api.hideProgress();
			if (status == 'success') {
				if (data.code == 200) {
					var pageParam = api.pageParam;
					pageParam.apply_status = 1;
					api.sendEvent({
					    name: 'practiceApplySucceedNotifi',
					    extra: pageParam
					});
					// setTimeout(function(){
					// 	api.closeWin({
					// 	    name: 'NewPracticeApply_win'
					// 	});
					// }, 1000);
					api.openFrame({
					    name: 'NewPracticeApplySucceed',
					    url: 'NewPracticeApplySucceed.html',
					    rect: {
					        x: 0,
					        y: 66,
					        w: 'auto',
					        h: api.winHeight - 66
					    },
					    pageParam: {
					        message: '等待审核保持电话畅通'
					    },
					    bounces: false
					});
				}else{
					api.toast({
					    msg: data.message
					});
				}
			}else{
				api.toast({
				    msg: '网络异常，请检查网络'
				});
			}
		});
	}  
</script>
</body>
</html>